<html>
 <head>
  <meta charset="UTF-8">
 </head>
 <body>
  <p data-lake-id="u3ef2e165" id="u3ef2e165"><span data-lake-id="u303b2c70" id="u303b2c70">​</span><br></p>
  <p data-lake-id="u832422ac" id="u832422ac"><span data-lake-id="ue3b90f35" id="ue3b90f35">背景：工作2年</span></p>
  <p data-lake-id="u8cadeb9f" id="u8cadeb9f"><br></p>
  <p data-lake-id="u459a52d1" id="u459a52d1"><span data-lake-id="u979dae5e" id="u979dae5e">面试问题：</span></p>
  <p data-lake-id="uc038ad40" id="uc038ad40"><br></p>
  <ol list="u68b9001e">
   <li fid="udb03412d" data-lake-id="u49a3b06f" id="u49a3b06f"><span data-lake-id="ubdf4068f" id="ubdf4068f">为什么找机会</span></li>
   <li fid="udb03412d" data-lake-id="ubbc2b487" id="ubbc2b487"><span data-lake-id="u04944955" id="u04944955">公司使用的技术栈是啥</span></li>
   <li fid="udb03412d" data-lake-id="u267bcb46" id="u267bcb46"><span data-lake-id="u28f95e22" id="u28f95e22">项目的最高QPS有多高</span></li>
   <li fid="udb03412d" data-lake-id="uebe863cd" id="uebe863cd"><span data-lake-id="u9471548f" id="u9471548f">遇到的开发问题有哪些？</span></li>
   <li fid="udb03412d" data-lake-id="u3f4fb24e" id="u3f4fb24e"><span data-lake-id="u95146429" id="u95146429">觉得自己从校招到现在有哪些提升</span></li>
   <li fid="udb03412d" data-lake-id="u9b0e8f64" id="u9b0e8f64"><span data-lake-id="u29e6c71d" id="u29e6c71d">项目-搭建的xx平台</span></li>
   <li fid="udb03412d" data-lake-id="u336daf03" id="u336daf03"><span data-lake-id="u0f59533a" id="u0f59533a">如何处理下游超时，一致性怎么保证</span></li>
  </ol>
  <ol list="u68b9001e" start="8">
   <li fid="udb03412d" data-lake-id="u04ecbc95" id="u04ecbc95"><span data-lake-id="u4a71dbc7" id="u4a71dbc7">RocketMq的特性</span></li>
  </ol>
  <ol list="u68b9001e" start="9">
   <li fid="udb03412d" data-lake-id="ubc332ae1" id="ubc332ae1"><span data-lake-id="u7e001d73" id="u7e001d73">如何用Redis统计亿级网站的uv</span></li>
  </ol>
  <ol list="u68b9001e" start="10">
   <li fid="udb03412d" data-lake-id="u058ebb10" id="u058ebb10"><span data-lake-id="u3595e6b5" id="u3595e6b5">遇到过什么线上问题，如何处理</span></li>
  </ol>
  <ol list="u68b9001e" start="11">
   <li fid="udb03412d" data-lake-id="uf8b65cdb" id="uf8b65cdb"><span data-lake-id="u0a11d867" id="u0a11d867">分布式锁如何设计</span></li>
  </ol>
  <ol list="u68b9001e" start="12">
   <li fid="udb03412d" data-lake-id="u53ed715c" id="u53ed715c"><span data-lake-id="u6ca5841e" id="u6ca5841e">分布式框架的服务发现怎么做</span></li>
  </ol>
  <ol list="u68b9001e" start="13">
   <li fid="udb03412d" data-lake-id="u74bbc5cc" id="u74bbc5cc"><span data-lake-id="u765ed14a" id="u765ed14a">TheadLocal的使用场景，如何防止内存泄露</span></li>
  </ol>
  <ol list="u68b9001e" start="14">
   <li fid="udb03412d" data-lake-id="ue1d23c45" id="ue1d23c45"><span data-lake-id="ucae2d971" id="ucae2d971">JVM的堆栈各存储什么内容</span></li>
  </ol>
  <ol list="u68b9001e" start="15">
   <li fid="udb03412d" data-lake-id="u15ca5d73" id="u15ca5d73"><span data-lake-id="u3174a598" id="u3174a598">写过什么公共组件么？</span></li>
   <li fid="udb03412d" data-lake-id="u462ec5d5" id="u462ec5d5"><span data-lake-id="u82cf3be5" id="u82cf3be5">反问：用增营销和交易营销的区别、技术栈，生活 作息等</span></li>
   <li fid="udb03412d" data-lake-id="u9eece4c6" id="u9eece4c6"><span data-lake-id="u6f1c67d6" id="u6f1c67d6">写题：</span></li>
  </ol>
  <pre lang="java"><code>
import java.util.Arrays;

public class Main {

    public static int[] findClosestElements(int[] arr, int k, int x) {
        //书写算法逻辑
        int left = 0, right = arr.length - 1;
        int mid = (left + right)/2;
        while(left &lt; right) {
            if(arr[mid] &gt; x) {
                right = mid;
            } else if(arr[mid] &lt; x) {
                left = mid + 1;
            } else {
                break;
            }
            mid = (left + right)/2;
        }
        int lp = mid, rp = mid, count = 1;
        while(count &lt; k) {
            if(rp &gt; arr.length - 1) {
                lp --;
            }
            if(lp &lt; 0) {
                rp ++;
            }
            if(x - arr[lp] &gt; arr[rp] - x) { 
                rp ++;
                
            } else {
                lp --;
            }
            count ++;
        }
        int[] ans = new int[rp - lp + 1];
        for(int i = lp; i &lt;= rp; i ++) { 
            ans[i - lp] = arr[i]; 
        }
        return ans;
    }

    // 获取到离x最近的k个数
    public static void main(String[] args) {
        int[] arr = {0, 0, 1, 2, 3, 3, 4, 7, 7, 8};
        int k = 3;
        int x = 5;
        int[] res = findClosestElements(arr, k, x);
        System.out.println(Arrays.toString(res));
    }
}

</code></pre>
 </body>
</html>